import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import './public-path';
Vue.config.productionTip = false;


let instance = null

function render(props = {}) {
  const { container } = props

  instance = new Vue({
    router,
    render: h => h(App)
  }).$mount(container ? container.querySelector('#app') : '#app')
}

// 独立运行时
if (!window.__POWERED_BY_QIANKUN__) {
  render()
}

// 导出 qiankun 生命周期函数
export async function bootstrap() {
  console.log('子应用A启动')
}

export async function mount(props) {
  console.log('子应用A挂载', props)
  render(props)
}

export async function unmount(props) {
  console.log('子应用A卸载')
  if (instance) {
    instance.$destroy()
    instance = null
  }
}